import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

// 实现增加功能
Blockly.Blocks.add_function = {
  init: function () {
    this.appendValueInput('add_function')
      .setCheck(null)
      .setAlign(Blockly.ALIGN_RIGHT)
      .appendField('.add')
    this.setInputsInline(true)
    this.setOutput(true, null)
    this.setColour(230)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

Blockly.Python.add_function = function (block) {
  const addContent = Blockly.Python.valueToCode(
    block,
    'add_function',
    Blockly.Python.ORDER_NONE
  )
  const code = '.add(' + addContent + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

export default Blockly
